package cn.edu.scau.Servlet;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;

import com.jspsmart.upload.SmartUpload;

public class ReceiveServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}


	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


		Collection<Part> files = req.getParts();


		for (Part part : files) {

			
			String filepath = part.getSubmittedFileName();


			int index = filepath.lastIndexOf("\\");

			String filename = filepath.substring(index + 1);


			part.write("g:/" + filename);
		}


		resp.getWriter().write("文件上传成功");
		resp.getWriter().close();

	}

}
